home *** CD-ROM | disk | FTP | other *** search
- /*
- * jpeg.h
- *
- * Copyright (C) 1991, 1992 Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This is the central file that's #include'd by all the JPEG .c files.
- * Its purpose is to provide a single place to fix any problems with
- * including the wrong system include files.
- * You can edit these declarations if you use a system with nonstandard
- * system include files.
- */
-
-
- #include <stdio.h>
- #include <stddef.h>
- #include <string.h>
- #include <bool.h>
-
- #define EIGHT_BIT_SAMPLES
- #define BITS_IN_JSAMPLE 8
-
- typedef unsigned char JSAMPLE;
-
- #define MAXJSAMPLE 255
- #define CENTERJSAMPLE 128
-
- typedef int JCOEF;
-
- #define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
- #define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
-
- typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
-
-
- typedef JCOEF DCTELEM;
- typedef DCTELEM DCTBLOCK[DCTSIZE2];
-
-
- typedef struct { /* Basic info about one component */
- short component_id; /* identifier for this component (0..255) */
- short component_index; /* its index in SOF or cinfo->comp_info[] */
- short h_samp_factor; /* horizontal sampling factor (1..4) */
- short v_samp_factor; /* vertical sampling factor (1..4) */
- short quant_tbl_no; /* quantization table selector (0..3) */
- short dc_tbl_no; /* DC entropy table selector (0..3) */
- short ac_tbl_no; /* AC entropy table selector (0..3) */
- } jpeg_component_info;
-
-
- /*
- * DCT coefficient quantization tables.
- * Note: the values in a QUANT_TBL are always given in zigzag order.
- */
-
- typedef int QUANT_VAL;
-
-
- #define NUM_QUANT_TBLS 4 /* quantization tables are numbered 0..3 */
- #define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
- #define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
- #define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
- #define MAX_BLOCKS_IN_MCU 10 /* JPEG limit on # of blocks in an MCU */
-
- /*
- * A Huffman coding table
- */
- typedef struct huff_code
- {
- long maxcode;
- unsigned char *codeptr;
- } HUFF_CODE;
-
- typedef struct
- {
- HUFF_CODE huff_code[18];
- unsigned char huffval[256];
- } HUFF_TBL;
-
- typedef struct
- {
- QUANT_VAL q[DCTSIZE2];
-
- } QUANT_TBL;
-
- typedef struct jpeg_tables
- {
- HUFF_TBL dc_huff_table[NUM_HUFF_TBLS];
- HUFF_TBL ac_huff_table[NUM_HUFF_TBLS];
- QUANT_TBL quant_table[NUM_QUANT_TBLS];
- } JPEG_TABLES;
-
- typedef struct dblock_info
- {
- JBLOCK *coeff_data;
- HUFF_TBL *dc_table;
- HUFF_TBL *ac_table;
- JCOEF *dc_prediction;
- QUANT_TBL *quant_table;
- } DBLOCK_INFO;
-
- /* Working data for decompression */
-
- struct decompress_info_struct
- {
- long image_width; /* overall image width */
- long image_height; /* overall image height */
-
- short data_precision; /* bits of precision in image data */
-
- short num_components; /* # of color components in JPEG image */
- jpeg_component_info comp_info[MAX_COMPS_IN_SCAN];
- short comps_in_scan; /* # of JPEG components input this time */
- jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
- };
-
- typedef struct decompress_info_struct * decompress_info_ptr;
-
- #define RST0 0xD0 /* RST0 marker code */
-
- extern int jpegGetByte(FILE *);
- extern int jpegGetWord(FILE *);
-